From e16d01d6a69f3482970f62dc3902a84cae0fb1ce Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Sat, 9 Feb 2002 04:14:53 +0000 Subject: [PATCH] Force all weight arrays to sum exactly to 65535. (Fixes #70971, reported Fri Feb 8 23:11:15 2002 Owen Taylor * pixops/pixops.c: Force all weight arrays to sum exactly to 65535. (Fixes #70971, reported by Federico Mena Quintero) * Makefile.am (libgdk_pixbuf_1_3_la_DEPENDENCIES): Add libpixops.la. --- gdk-pixbuf/ChangeLog | 8 ++++++++ gdk-pixbuf/Makefile.am | 2 +- gdk-pixbuf/pixops/pixops.c | 32 ++++++++++++++++++++++++++------ 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index 6e32150ab6..45f4708424 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -1,3 +1,11 @@ +Fri Feb 8 23:11:15 2002 Owen Taylor + + * pixops/pixops.c: Force all weight arrays to sum exactly + to 65535. (Fixes #70971, reported by Federico Mena Quintero) + + * Makefile.am (libgdk_pixbuf_1_3_la_DEPENDENCIES): Add + libpixops.la. + 2002-02-08 Federico Mena Quintero * pixops/pixops.h: Fix comment; PixopsInterpType -> GdkInterpType. diff --git a/gdk-pixbuf/Makefile.am b/gdk-pixbuf/Makefile.am index e72011e37e..0c79e995f6 100644 --- a/gdk-pixbuf/Makefile.am +++ b/gdk-pixbuf/Makefile.am @@ -263,7 +263,7 @@ libgdk_pixbuf_1_3_la_LDFLAGS = @STRIP_BEGIN@ \ @STRIP_END@ libgdk_pixbuf_1_3_la_LIBADD = pixops/libpixops.la $(builtin_objs) $(GDK_PIXBUF_DEP_LIBS) -libgdk_pixbuf_1_3_la_DEPENDENCIES = $(builtin_objs) $(gdk_pixbuf_def) +libgdk_pixbuf_1_3_la_DEPENDENCIES = pixops/libpixops.la $(builtin_objs) $(gdk_pixbuf_def) gdk_pixbuf_headers = \ gdk-pixbuf.h \ diff --git a/gdk-pixbuf/pixops/pixops.c b/gdk-pixbuf/pixops/pixops.c index 201c17c0e6..12ba7f754c 100644 --- a/gdk-pixbuf/pixops/pixops.c +++ b/gdk-pixbuf/pixops/pixops.c @@ -1098,6 +1098,7 @@ tile_make_weights (PixopsFilter *filter, double x_scale, double y_scale, double double x = (double)j_offset / SUBSAMPLE; double y = (double)i_offset / SUBSAMPLE; int i,j; + int total = 0; for (i = 0; i < n_y; i++) { @@ -1105,6 +1106,7 @@ tile_make_weights (PixopsFilter *filter, double x_scale, double y_scale, double if (i < y) { + if (i + 1 > y) th = MIN(i+1, y + 1/y_scale) - y; else @@ -1120,6 +1122,8 @@ tile_make_weights (PixopsFilter *filter, double x_scale, double y_scale, double for (j = 0; j < n_x; j++) { + int weight; + if (j < x) { if (j + 1 > x) @@ -1135,8 +1139,12 @@ tile_make_weights (PixopsFilter *filter, double x_scale, double y_scale, double tw = 0; } - *(pixel_weights + n_x * i + j) = 65536 * tw * x_scale * th * y_scale * overall_alpha; + weight = 65536 * tw * x_scale * th * y_scale * overall_alpha + 0.5; + total += weight; + *(pixel_weights + n_x * i + j) = weight; } + + *(pixel_weights + n_x * n_y - 1) += 65536 - total; } } } @@ -1184,7 +1192,8 @@ bilinear_make_fast_weights (PixopsFilter *filter, double x_scale, double y_scale double x = (double)j_offset / SUBSAMPLE; double y = (double)i_offset / SUBSAMPLE; int i,j; - + int total = 0; + if (x_scale > 1.0) /* Bilinear */ { for (i = 0; i < n_x; i++) @@ -1251,7 +1260,13 @@ bilinear_make_fast_weights (PixopsFilter *filter, double x_scale, double y_scale for (i = 0; i < n_y; i++) for (j = 0; j < n_x; j++) - *(pixel_weights + n_x * i + j) = 65536 * x_weights[j] * x_scale * y_weights[i] * y_scale * overall_alpha + 0.5; + { + int weight = 65536 * x_weights[j] * x_scale * y_weights[i] * y_scale * overall_alpha + 0.5; + *(pixel_weights + n_x * i + j) = weight; + total += weight; + } + + *(pixel_weights + n_x * n_y - 1) += 65536 - total; } g_free (x_weights); @@ -1336,19 +1351,24 @@ bilinear_make_weights (PixopsFilter *filter, double x_scale, double y_scale, dou double x = (double)j_offset / SUBSAMPLE; double y = (double)i_offset / SUBSAMPLE; int i,j; - + int total = 0; + for (i = 0; i < n_y; i++) for (j = 0; j < n_x; j++) { double w; + int weight; w = bilinear_quadrant (0.5 + j - (x + 1 / x_scale), 0.5 + j - x, 0.5 + i - (y + 1 / y_scale), 0.5 + i - y); w += bilinear_quadrant (1.5 + x - j, 1.5 + (x + 1 / x_scale) - j, 0.5 + i - (y + 1 / y_scale), 0.5 + i - y); w += bilinear_quadrant (0.5 + j - (x + 1 / x_scale), 0.5 + j - x, 1.5 + y - i, 1.5 + (y + 1 / y_scale) - i); w += bilinear_quadrant (1.5 + x - j, 1.5 + (x + 1 / x_scale) - j, 1.5 + y - i, 1.5 + (y + 1 / y_scale) - i); - - *(pixel_weights + n_x * i + j) = 65536 * w * x_scale * y_scale * overall_alpha; + weight = 65536 * w * x_scale * y_scale * overall_alpha + 0.5; + *(pixel_weights + n_x * i + j) = weight; + total += weight; } + + *(pixel_weights + n_x * n_y - 1) += 65536 - total; } } -- 2.30.2